// 封装showToast
export const showMsg = (options = {}, icon = 'none', duration = 1500) => {

	// 设置默认值
	let config = {};
	if (typeof options === 'string') {
		config = {
			title: options,
			icon,
			duration
		}
	} else {
		config = {
			title: options.title || '请求失败，请稍后重试！',
			icon: options.icon || 'none',
			duration: options.duration || 1500
		}
	}
	return new Promise((resolve, reject) => {
		uni.showToast({
			title: config.title,
			icon: config.icon,
			mask: true,
			duration: config.duration,
			success: (res) => {
				setTimeout(() => {
					resolve(res);
				}, config.duration)
			},
			fail: (err) => {
				reject(err);
			}
		});
	});
}